package com.bwie.service.impl;

import com.bwie.common.domain.Customer;
import com.bwie.common.domain.Dict;
import com.bwie.common.domain.User;
import com.bwie.mapper.DictMapper;
import com.bwie.service.DictService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @className: DictServiceImpl
 * @Description: TODO
 * @version: v1.８.0
 * @author: GONGWENXUE
 * @date: 2025/10/10 13:54
 */
@Service
public class DictServiceImpl implements DictService {
    @Autowired
    DictMapper dictMapper;
    @Autowired
    RedisTemplate redisTemplate;

    @Override
    public List<Dict> typeDrop() {
        Boolean aBoolean = redisTemplate.hasKey("type");
        if(aBoolean){
            List<Dict> type = (List<Dict>) redisTemplate.opsForValue().get("type");
            return type;
        }
        List<Dict> dictList=dictMapper.typeDrop();
        redisTemplate.opsForValue().set("type",dictList);
        return dictList;
    }

    @Override
    public List<Dict> sourceDrop() {
        Boolean aBoolean = redisTemplate.hasKey("source");
        if(aBoolean){
            List<Dict> source= (List<Dict>) redisTemplate.opsForValue().get("source");
            return source;
        }
        List<Dict> dicts=dictMapper.source();
        redisTemplate.opsForValue().set("source",dicts);
        return dicts;
    }

    @Override
    public List<Dict> stageDrop() {
        return dictMapper.stageDrop();
    }

    @Override
    public List<Dict> rateDrop() {
        return dictMapper.rateDrop();
    }

    @Override
    public List<Customer> UserDrop() {
        return dictMapper.userDrop();
    }

    @Override
    public List<User> sysDrop() {
        return dictMapper.sysDrop();
    }
}